<script setup>
import { payOrderService } from '@/api/order'

import { ref, onMounted } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter()
const p = ref()

const init = async () => {
    const data = sessionStorage.getItem('orderId')
    if (!data) {
        return router.push('/')
    }
    console.log('收到的订单id：', data);
    try {
        const res = await payOrderService(data)
        p.value.innerHTML = res.data;
        p.value.childNodes[0].submit();
    } catch (err) {
        // console.log(err);
        setTimeout(() => {
            window.close()
        }, 1000)

    }

}

onMounted(() => {
    init()
})

</script>
<template>
    <div>
        <div ref="p" style="display:none"></div>
    </div>
</template>
<style scoped lang='scss'></style>